<?php 
use yii\helpers\Html;
use yii\widgets\ActiveForm;
 ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong><span class="icon-key"></span> 分配权限</strong></div>
  <div class="body-content">
<?php $form = ActiveForm::begin(['action'=>['right/allot'],'options'=>['class' => 'form-x']]);  ?>
      <div class="form-group">
        <div class="label">
          <label for="sitename">管理员名称：</label><input type="hidden" value="<?=$data['admin']['admin_id'] ?>" name="admin_id">
        </div>
        <div class="field">
          <label style="line-height:33px;">
           <?=$data['admin']['admin_name'] ?>
          </label>
        </div>
      </div>      
      <div class="form-group">
        <div class="label">
          <label for="sitename">分配权限：</label>
        </div>
        <div class="field">
          <?php //echo "<pre>";print_r($data) ?>
          <?php foreach ($data['relation_all'] as $key => $value): ?>
          <?php $key_count = count($data['relation_all'])-1 ?>
          <?php $new_key = ($key+1)>=$key_count?$key_count:$key+1 ?>
          <?=$value['name']?>:<input type="checkbox" name="right_id[]" value="<?=$value['id']?>" 
          <?php foreach ($data['admin_relation'] as $ke => $val) { ?>
          <?php if ($val['name']==$value['name']) { ?>
                checked="checked"
          <?php } ?>
          <?php } ?>>
          <?php if($data['relation_all'][$new_key]['a']==0) { ?>
                <br>
          <?php } ?>
          <?php endforeach ?>
        </div>
      </div>      
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 分配</button>   
        </div>
      </div>      
<?php ActiveForm::end(); ?> 
  </div>
</div>
</body></html>